package test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCTut {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try{
			Connection con;
			//Dirvermanager kennt alle treiber
			//localhost = IP-Adresse, root, pw
			//Connection erstellen
			con = DriverManager.getConnection("jdbc:mysql://localhost","root", "");
			//statment setzt connection voraus
			Statement s = con.createStatement();
			
			String createDatabaseSchule = "Create Database if not exists Schule";
			s.executeUpdate(createDatabaseSchule);
			
			createDatabaseSchule = "select name,vorname from dreamhome.mitarbeiter";
			ResultSet rs = s.executeQuery(createDatabaseSchule);
			
			while (rs.next()){
				String prename = rs.getString(1);
				String lastname = rs.getString(2);
				System.out.println(prename + " " + lastname);
			}
			
			//Alles schliessen
			s.close();
			con.close();
		}
		catch (Exception e){
			System.out.println(e);
		}

	}

}
